<include file="public@header" />

</head>

<body>
	<style type="text/css">
		td {
			text-align: center;
			display: table-cell;
			vertical-align: middle
		}
		.black{font-weight:bold }
		/*td {background-color: #00ff00}*/
	</style>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
<!-- 
			<li class="active" id="list"><a href="{:url('Park/index')}">孵化器</a></li>
			<li><a href="{:url('Park/addPark')}">添加</a></li> -->
			<!-- 	<li><a href="{:url('user/add')}">{:lang('ADMIN_USER_ADD')}</a></li> -->
		</ul>
		<form class="well form-inline margin-top-20" metdod="post" action="{:url('Summary/index')}">

			时间选择:
			<input type="text" class="form-control js-bootstrap-datetime" name="start_time" value="{$start_time|default=''}" style="width: 140px;" autocomplete="off">-
			<input type="text" class="form-control js-bootstrap-datetime" name="end_time" value="{$end_time|default=''}" style="width: 140px;" autocomplete="off"> &nbsp; &nbsp;
			所属园区:
			<select class="form-control" name="incubator_id" style="width: 140px;">
				<option value="">==请选择==</option>
				<volist name="incubator_list" id="vo">
				<option value="{$vo.id}" <if condition="$incubator_id eq $vo.id">selected</if>>{$vo.incubator_name}</option>
				</volist>

			</select> &nbsp;&nbsp;
		

			<input type="submit" class="btn btn-primary" value="搜索" />
			<a class="btn btn-danger" href="{:url('Summary/index')}">清空</a>
		</form>
		<table>
      <tr>
        <th>运营统计</th>
        <td>订单数（个）</td>
        <td>本期应收总额(元)</td>
        <td>本期实收总额(元)</td>
        <td>总成交面积(平米)</td>
        <td>总入孵企业(个)</td>
        <td>租金总额(元)</td>
        <td>押金总额(元)</td>
      </tr>
      <tr>
        <th></th>
        <td class="black">{$list.total_order} </td>
        <td class="black">{$list.sum_price}</td>
        <td class="black">{$list.actual_total_rent}</td>
        <td class="black">{$list.total_area}</td>
        <td class="black">{$list.company_num}</td>
        <td class="black">{$list.total_rent}</td>
        <td class="black">{$list.total_deposit}</td>
      </tr>
      <tr>
        <th>客户统计</th>
        <td>总客户数（位）</td>
        <td>客户领域</td>
        <td>客户投资阶段</td>
        <td>入孵渠道</td>
      </tr>
      <tr>
        <th></th>
        <td>{$list.customer_num}</td>
        <td>
          <div id="mains" style="width: 300px;height:200px;"></div>
        </td>
        <td>
          <div id="main" style="width: 300px;height:200px;"></div>
        </td>
        <td>
          <div id="link" style="width: 300px;height:200px;"></div>
        </td>
      </tr>
      <tr>
        <th>园区统计</th>
        <td>总面积（平米）</td>
        <td>总办公室数（间）</td>
        <td>已租／未租</td>
        <td>空置率</td>
      </tr>
      <tr>
        <th></th>
        <td class="black">{$list.park_space_area}</td>
        <td class="black">{$list.park_space_num}</div>
        <td class="black">
      		<div id="park_rent" style="width: 300px;height:200px;"></div>
      	</td>
      	<td>
      		<div id="empty" style="width: 300px;height:200px;"></div>
      	</td>
      </tr>
      <tr>
        <th>众创空间统计</th>
        <td>总工位（个）</td>
        <td>总办公室数（间）</td>
        <td>工位空置率</td>
        <td>办公室空置率</td>
      </tr>
      <tr>
        <th></th>
        <td class="black">{$list.station_num}</td>
        <td class="black">{$list.space_num}</div>
        <td>
          <div id="emptys" style="width: 300px;height:200px;"></div>
        </td>
        <td>
          <div id="emptyroom" style="width: 300px;height:200px;"></div>
        </td>
      </tr>
      <tr>
        <th>退租</th>
        <td>退租原因</td>
        <td>月退租数</td>
      </tr>
      <tr>
        <th></th>
        <td widtd="50">
          <div id="reason" style="width: 300px;height:200px;">
        </td>
        <td>
          <div id="monthlost" style="width: 300px;height:200px;">
        </td>
      </tr>
      <tr>
        <th>场地统计</th>
        <td class="black">{$list.site_num}</td>
      </tr>
    </table>

	</div>

	<script src="__STATIC__/js/admin.js"></script>
	<script src="__STATIC__/js/echarts.js"></script>
</body>

<body>
	<!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->

	<script type="text/javascript">

		// 基于准备好的dom，初始化echarts实例
		var stime="<?php echo $start_time ; ?>";
		var etime="<?php echo $end_time ; ?>";
		var incubator_id="<?php echo $incubator_id ; ?>";

		var myChart = echarts.init(document.getElementById('mains'));
		var myCharts = echarts.init(document.getElementById('main'));
		var myChartl = echarts.init(document.getElementById('link'));
		var myChartp = echarts.init(document.getElementById('park_rent'));
		var myChartr = echarts.init(document.getElementById('reason'));
		// myChart.setOption({
		// 	tooltip : {
		// 		trigger: 'item',
		// 		formatter: "{a} <br/>{b} : {c} ({d}%)"
		// 	},
		// 	series : [
		// 	{
		// 		name: '访问来源',
		// 		type: 'pie',
		// 		radius : '55%',
		// 		center: ['50%', '60%'],
		// 		data:[
		// 		{value:335, name:'直接访问'},
		// 		{value:310, name:'邮件营销'},
		// 		{value:234, name:'联盟广告'},
		// 		{value:135, name:'视频广告'},
		// 		{value:1548, name:'搜索引擎'}
		// 		],
		// 		itemStyle: {
		// 			emphasis: {
		// 				shadowBlur: 10,
		// 				shadowOffsetX: 0,
		// 				shadowColor: 'rgba(0, 0, 0, 0.5)'
		// 			}
		// 		}
		// 	}
		// 	]
		//  })







		var showarr = [];
		var showobj = {};
		$.post("{:url('Summary/customerFields')}", {start_time:stime,end_time:etime,incubator_id:incubator_id}, function(data, status) {
			$.each(data, function(i, j) {

				//alert(i);
				//alert(j);
				showobj = {
					value: j.count,
					name: j.name
				};
				showarr.push(showobj);
				//alert(data);


			})
			// console.log(showarr);
			chart(myChart, showarr);


		})

		var showarrs = [];
		var showobjs = {};
		$.post("{:url('Summary/customerStage')}", {start_time:stime,end_time:etime,incubator_id:incubator_id}, function(data, status) {
			$.each(data, function(i, j) {

				//alert(i);
				//alert(j);
				showobjs = {
					value: j.count,
					name: j.name
				};
				showarrs.push(showobjs);
				//alert(data);


			})
			// console.log(showarr);
			chart(myCharts, showarrs);


		})
		var showarrl = [];
		var showobjl = {};
		$.post("{:url('Summary/linkRate')}", {start_time:stime,end_time:etime,incubator_id:incubator_id}, function(data, status) {
			$.each(data, function(i, j) {

				//alert(i);
				//alert(j);
				showobjl = {
					value: j.count,
					name: j.name
				};
				showarrl.push(showobjl);
				//alert(data);


			})
			// console.log(showarr);
			chart(myChartl, showarrl);


		})
		var showarrr = [];
		var showobjr = {};
		$.post("{:url('Summary/lostRent')}", {start_time:stime,end_time:etime,incubator_id:incubator_id}, function(data, status) {
			$.each(data, function(i, j) {

				//alert(i);
				//alert(j);
				showobjr = {
					value: j.count,
					name: j.name
				};
				showarrr.push(showobjr);
				//alert(data);


			})
			// console.log(showarr);
			chart(myChartr, showarrr);


		})
		var showarrp = [];
		var showobjp = {};
		$.post("{:url('Summary/rentRate')}", {start_time:stime,end_time:etime,incubator_id:incubator_id}, function(data, status) {
			$.each(data, function(i, j) {

				//alert(i);
				//alert(j);
				showobjp = {
					value: j.count,
					name: j.name
				};

				showarrp.push(showobjp);
				//alert(data);


			})

			chart(myChartp, showarrp);


		})

		function chart(myChartl, data) {

			myChartl.setOption({
				tooltip: {
					trigger: 'item',
					formatter: "{a} <br/>{b} : {c} ({d}%)"
				},
				series: [{
					name: '访问来源',
					type: 'pie',
					radius: '55%',
					center: ['50%', '60%'],
					data: data,
					itemStyle: {
						emphasis: {
							shadowBlur: 10,
							shadowOffsetX: 0,
							shadowColor: 'rgba(0, 0, 0, 0.5)'
						}
					},
                    
                //     label: {
                //     normal: {
                //         position: 'inside'
                //     }
                // }
				}]
			})






		}
		var myChartempty = echarts.init(document.getElementById('empty'));

		var showarrp1 = [];
		var showarrp2 = [];
		var showobjp = {};
		$.post("{:url('Summary/parkRate')}",{start_time:stime,end_time:etime,incubator_id:incubator_id}, function(data, status) {
			$.each(data, function(i, j) {

				//alert(i);
				//alert(j);
				//showobjp={value:j.count,name:j.name};
				showarrp1.push(j.month);
				showarrp2.push(j.rate);
				//alert(data);


			})
			//  console.log(showarrp1);
			chart_line(myChartempty, showarrp1, showarrp2,'园区房间空置率');


		})

		var myChartsempty = echarts.init(document.getElementById('emptys'));

		var showarrps = [];
		var showarrps2 = [];
		var showobjps = {};
		$.post("{:url('Summary/parkRate')}", {
			type: 2,
			sit: 2,start_time:stime,end_time:etime,incubator_id:incubator_id
		}, function(data, status) {
			$.each(data, function(i, j) {

				//alert(i);
				//alert(j);
				//showobjp={value:j.count,name:j.name};
				showarrps.push(j.month);
				showarrps2.push(j.rate);
				//alert(data);


			})

			chart_line(myChartsempty, showarrps, showarrps2,'工位空置率');


		})
		var myChartroom = echarts.init(document.getElementById('emptyroom'));

		var showarrproom = [];
		var showarrproom2 = [];
		$.post("{:url('Summary/parkRate')}", {
			type: 2,start_time:stime,end_time:etime,incubator_id:incubator_id
		}, function(data, status) {
			$.each(data, function(i, j) {

				//alert(i);
				//alert(j);
				//showobjp={value:j.count,name:j.name};
				showarrproom.push(j.month);
				showarrproom2.push(j.rate);
				//alert(data);


			})
			// console.log(showarrroom);
			chart_line(myChartroom, showarrproom, showarrproom2,'众创房间空置率');


		})

		var myChartlost = echarts.init(document.getElementById('monthlost'));

		var showarrlost = [];
		var showarrlost2 = [];
		$.post("{:url('Summary/monthLost')}", {start_time:stime,end_time:etime,incubator_id:incubator_id}, function(data, status) {
			$.each(data, function(i, j) {

				//alert(i);
				//alert(j);
				//showobjp={value:j.count,name:j.name};
				showarrlost.push(j.month);
				showarrlost2.push(j.count);
				//alert(data);


			})
			// console.log(showarrroom);
			chart_line(myChartlost, showarrlost, showarrlost2,'月退租个数');


		})









		function chart_line(myChartp, data1, data2,name) {

			myChartp.setOption({
				title: {
					text: ''
				},
				tooltip: {
					trigger: 'axis',
					axisPointer: {
						type: 'cross',
						label: {
							backgroundColor: '#6a7985'
						}
					}
				},
				toolbox: {
					feature: {
						saveAsImage: {}
					}
				},
				grid: {
					left: '3%',
					right: '4%',
					bottom: '3%',
					containLabel: true
				},
				xAxis: [{
					type: 'category',
					boundaryGap: false,
					data: data1
				}],
				yAxis: [{
					type: 'value'
				}],
				series: [{
					name: name,
					type: 'line',
					stack: '总量',
					label: {
						normal: {
							show: true,
							position: 'top'
						}
					},
					data: data2
				}]
			});



		}
		$(".space_type").change(function(){
		var b=$(".space_name option:first").text();  
		$(".space_name").html("<option value=''>"+b+"</option>");  
        var type=$(".space_type").val();
        var option;
        $.post("{:url('Order/get_space')}",{type:type,edit:'',space_id:'',incubator_id:incubator_id},function(data,status){
        		$.each(data,function(i,j){

        			if(type==1){
        				option+='<option class='+j.incubator_id+' value='+j.id+'>'+j.station_name+'</option>';	
        			}else{
        				option+='<option class='+j.incubator_id+' value='+j.id+'>'+j.site_name+'</option>';
        			}
        		
        		})
        		$(".space_name").append(option);
        })
       // alert(option);
	})

		// 使用刚指定的配置项和数据显示图表。
		//myChart.setOption(option);
	</script>
</body>

</html>
<!-- <script>
	$(function(){

	})
	$(".del").click(
	    function(){
	    if(confirm("确认要删除吗")){
	    	    var id=$(tdis).attr("id");
	    	    $.post("{:url('delPark')}",
	    		{id:id},
	    		function(data,status){

	    			location.href="{:url('index')}";
	    		});
	    }


	    }
	);



</script> -->
